package com.digitalchina.lxnsy.api;

import android.app.Activity;
import android.os.Handler;

import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.digitalchina.lxnsy.xml.LocationXML;
import com.digitalchina.lxnsy.xml.UserXML;
import com.lzy.okhttputils.model.HttpParams;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：关于抽奖api
 * 包名：com.digitalchina.bigdata.api
 * 创建人：郑皓
 * 创建时间：2018/3/23 17:16
 * 修改备注：
 * ================================================
 */
public class BusinessLottery {

    /**
     * 获取奖品信息  包含奖品 中奖名单 抽奖规则说明
     *
     * @param activity
     * @param handler
     */
    public static void getPrizeList(Activity activity, Handler handler) {
        HttpParams params = new HttpParams();

        OkHttpUtil.post(activity, URL.URL_GET_PRIZE_LIST, "",
                params, handler, MSG.MSG_GET_PRIZE_LIST_SUCCESS, MSG.MSG_GET_PRIZE_LIST_FIELD);
    }


    /**
     * 抽奖
     *
     * @param activity
     * @param handler
     */
    public static void drawPrize(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("provinceName", LocationXML.getProvince(activity));
        params.put("cityName", LocationXML.getCity(activity));

        OkHttpUtil.post(activity, URL.URL_DRAW_PRIZE, "正在抽奖...",
                params, handler, MSG.MSG_DRAW_PRIZE_SUCCESS, MSG.MSG_DRAW_PRIZE_FIELD);
    }


    /**
     * 查询剩余次数
     *
     * @param activity
     * @param handler
     */
    public static void queryLotteryNum(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_QUERY_LOTTERY_NUM, "",
                params, handler, MSG.MSG_QUERY_LOTTERY_NUM_SUCCESS, MSG.MSG_QUERY_LOTTERY_NUM_FIELD);
    }


    /**
     * 分享后 抽奖次数+1
     *
     * @param activity
     * @param handler
     */
    public static void shareNum(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("id", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_SHARE_NUM, "",
                params, handler, MSG.MSG_SHARE_NUM_SUCCESS, MSG.MSG_SHARE_NUM_FIELD);
    }


    /**
     * 我的中奖记录
     *
     * @param activity
     * @param page
     * @param limit
     * @param handler
     */
    public static void raffleInfo(Activity activity, int page, int limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));

        OkHttpUtil.post(activity, URL.URL_RAFFLE_INFO, "",
                params, handler, MSG.MSG_RAFFLE_INFO_SUCCESS, MSG.MSG_RAFFLE_INFO_FIELD);
    }


    /**
     * 领奖
     * @param activity
     * @param id  奖品id
     * @param handler
     */
    public static void lottmageUpdate(Activity activity, String id, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("id", id);

        OkHttpUtil.post(activity, URL.URL_LOTTMAGE_UPDATE, "",
                params, handler, MSG.MSG_LOTTMAGE_UPDATE_SUCCESS, MSG.MSG_LOTTMAGE_UPDATE_FIELD);
    }

}
